package com.tsd.core.vo;


import com.tsd.core.utils.Transform;

/**
 * 数据库字段封装类
 */
public class ColumnClass {

    /**
     * 数据库表名称
     **/
    private String tableName;
    /**
     * 数据库字段名称
     **/
    private String columnName;
    /**
     * 数据库字段类型
     **/
    private String columnType;
    /**
     * 数据库字段首字母小写且去掉下划线字符串
     **/
    private String changeColumnName;
    /**
     * 数据库字段注释
     **/
    private String columnComment;
    /**
     * 是否主键
     **/
    private Integer isPk = 0;
    /**
     * 数据长度
     */
    private int length;
    /**
     * 小数位数
     */
    private int fraction_len;

    /**
     * 是否自增：0-否、1-是
     */
    private Integer isAutoIncrement = 0;

    private int position;

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public String getColumnName() {
        return columnName;
    }

    public void setColumnName(String columnName) {
        this.columnName = columnName;
    }

    public String getColumnType() {
        switch (columnType.toLowerCase()) {
            case "int":
                columnType = "INTEGER";
                break;
            case "datetime":
                columnType = "TIMESTAMP";
                break;
            case "text":
                columnType = "VARCHAR";
                break;
            case "longtext":
                columnType = "LONGVARCHAR";
                break;
        }
        return columnType;
    }

    public void setColumnType(String columnType) {
        this.columnType = columnType;
    }

    public String getChangeColumnName() {
        return changeColumnName;
    }

    public void setChangeColumnName(String changeColumnName) {
        this.changeColumnName = changeColumnName;
    }

    public String getColumnComment() {
        return columnComment;
    }

    public void setColumnComment(String columnComment) {
        this.columnComment = columnComment;
    }

    public Integer getIsPk() {
        return isPk;
    }

    public void setIsPk(Integer isPk) {
        this.isPk = isPk;
    }

    public String getJavaType() {
        return Transform.getJavaType(columnType);
    }

    public Integer getIsAutoIncrement() {
        return isAutoIncrement;
    }

    public void setIsAutoIncrement(Integer isAutoIncrement) {
        this.isAutoIncrement = isAutoIncrement;
    }

    public int getLength() {
        return length;
    }

    public void setLength(int length) {
        this.length = length;
    }

    public int getFraction_len() {
        return fraction_len;
    }

    public void setFraction_len(int fraction_len) {
        this.fraction_len = fraction_len;
    }

    public int getPosition() {
        return position;
    }

    public void setPosition(int position) {
        this.position = position;
    }
}

